# -*- coding:utf-8 -*-
'''
@Author: lindes
'''
from rest_framework import serializers
from article.models import CommentArticle
from good_article.models import CommentGoodArticle
from users.models import UserProfile
from users.serializers import UserSerializerLite


# 对文章评论的两个序列化器
class ReplyCommentArticleSerializer(serializers.ModelSerializer):
    """
    Comment序列化器, 用于序列化 被回复者 的信息
    """
    user = UserSerializerLite(read_only=True)

    class Meta:
        model = CommentArticle
        fields = "__all__"


class CommentArticleSerializer(serializers.ModelSerializer):
    """
    Comment序列化器
    """
    pid = ReplyCommentArticleSerializer(read_only=True)
    user = UserSerializerLite(read_only=True)

    class Meta:
        model = CommentArticle
        fields = ("id", "pid", "add_time", "user")


# 对识货评论的两个序列化器
class ReplyCommentGoodArticleSerializer(serializers.ModelSerializer):
    """
    Comment序列化器, 用于序列化 被回复者 的信息
    """
    user = UserSerializerLite(read_only=True)

    class Meta:
        model = CommentGoodArticle
        fields = "__all__"


class CommentGoodArticleSerializer(serializers.ModelSerializer):
    """
    Comment序列化器
    """
    pid = ReplyCommentGoodArticleSerializer(read_only=True)
    user = UserSerializerLite(read_only=True)

    class Meta:
        model = CommentGoodArticle
        fields = ("id", "pid", "add_time", "user")


# 对动态评论的两个序列化器
class ReplyPostSerializer(serializers.ModelSerializer):
    """
    Comment序列化器, 用于序列化 被回复者 的信息
    """
    user = UserSerializerLite(read_only=True)

    class Meta:
        model = CommentGoodArticle
        fields = "__all__"


class CommentPostSerializer(serializers.ModelSerializer):
    """
    Comment序列化器
    """
    pid = ReplyCommentGoodArticleSerializer(read_only=True)
    user = UserSerializerLite(read_only=True)

    class Meta:
        model = CommentGoodArticle
        fields = ("id", "pid", "add_time", "user")
